package com.gimi.cloud.jimi.dao.dao.userInfo;

import com.gimi.cloud.jimi.dao.dao.sys.BaseDao;
import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dao.myMapper.core.query.QueryParam;
import com.gimi.cloud.jimi.dao.myMapper.core.query.QueryParamProvider;
import com.gimi.cloud.jimi.dto.userInfo.UserAppInformationDTO;
import com.gimi.cloud.jimi.entity.userInfo.UserAppInformation;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

@Mapper
public interface UserAppInformationDao extends MyMapper<UserAppInformation>,BaseDao<UserAppInformation, UserAppInformationDTO> {

	@InsertProvider(method = "insertUserInformationSql", type = UserAppInformationDaoProvider.class)
	void insertUserInformation(Integer userId, int appIdentify, String appVersion, double latitude, double longitude,
                               String address, String ip, String uniqueInformation, String idfa, String unitType, String operators,
                               String channelId, String appId, int userAction, int saveType, String ipLocation);

	/**
	 * 获取用户登录记录总条数
	 * @param userId
	 * @return
	 */
	@Select("SELECT COUNT(1) FROM `rd_user_app_information` WHERE user_id = #{userId}")
	Integer getCountByUser(Integer userId);

	@SelectProvider(type = QueryParamProvider.class, method = "selectListBySql")
	List<UserAppInformationDTO> getUserAppInfomationListPage(QueryParam queryParam);
}
